/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author QUY_THI
 */
@Entity
@Table(name = "Transfers")
@NamedQueries({
    @NamedQuery(name = "Transfer.findAll", query = "SELECT t FROM Transfer t"),
    @NamedQuery(name = "Transfer.findByTransferID", query = "SELECT t FROM Transfer t WHERE t.transferID = :transferID"),
    @NamedQuery(name = "Transfer.findByAmount", query = "SELECT t FROM Transfer t WHERE t.amount = :amount"),
    @NamedQuery(name = "Transfer.findByTransactionDate", query = "SELECT t FROM Transfer t WHERE t.transactionDate = :transactionDate")})
public class Transfer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "TransferID")
    private Integer transferID;
    @Basic(optional = false)
    @Column(name = "Amount")
    private BigDecimal amount;
    @Column(name = "TransactionDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date transactionDate;
    @JoinColumn(name = "AccountReceive", referencedColumnName = "AcountCode")
    @ManyToOne
    private Account account;
    @JoinColumn(name = "AccountTransfer", referencedColumnName = "AcountCode")
    @ManyToOne
    private Account account1;

    public Transfer() {
    }

    public Transfer(Integer transferID) {
        this.transferID = transferID;
    }

    public Transfer(Integer transferID, BigDecimal amount) {
        this.transferID = transferID;
        this.amount = amount;
    }

    public Integer getTransferID() {
        return transferID;
    }

    public void setTransferID(Integer transferID) {
        this.transferID = transferID;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Date getTransactionDate() {
        return transactionDate;
    }

    public void setTransactionDate(Date transactionDate) {
        this.transactionDate = transactionDate;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Account getAccount1() {
        return account1;
    }

    public void setAccount1(Account account1) {
        this.account1 = account1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (transferID != null ? transferID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transfer)) {
            return false;
        }
        Transfer other = (Transfer) object;
        if ((this.transferID == null && other.transferID != null) || (this.transferID != null && !this.transferID.equals(other.transferID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Transfer[transferID=" + transferID + "]";
    }

}
